<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>添加服务商</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/yzl.css"/>

</head>
<body>
<div id="blank" class="header" style="border-bottom:1px solid #D6D6D6;color:#000">
    <div v-back.tapmode class="back"></div>
    <span class="title">确认订购信息</span>
</div>
<div id="app" class="top-container shop-info" v-cloak>
    <div class="shop-info-top" style="">手机号码：{{level.phone}}</div>
      <div class="add-info" style="margin-top:10px">
        <div>服务类型:</div>
        <div>{{level.type==5?"VIP会员":"店铺"}}</div>
        <div style="clear:both"></div>
      </div>
      <div class="add-info">
        <div>生效周期:</div>
        <div>
          <div>{{level.duration_type==1?"365天":"永久"}}</div>
          <div>付费后立即生效</div>
        </div>
        <div style="clear:both"></div>
      </div>
      <div class="add-info">
        <div>服务价格:</div>
        <div style="color:#9d0152;font-size:15px;">￥{{level.need_pay_total}}</div>
        <div style="clear:both"></div>
      </div>
      <div class="add-info" style="margin-top:10px">
        <div>合计:</div>
        <div style="color:#9d0152;font-size:15px;">￥{{level.need_pay_total}}</div>
        <div style="clear:both"></div>
      </div>
    <div class="btn-commit" style="background:#9D0152" v-myclick="addMember">确认新增</div>
</div>
</body>
<script src="../../script/api.js"></script>
<script src="../../script/vue.js"></script>
<script src="../../script/app.js"></script>
<script src="../../script/common.js"></script>
<script src="../../script/url.js"></script>
<script>

var level,
    wap_url,
    vm;
apiready = function () {
    showProgress();
    setBSImg();

    new Vue({
        el: '#blank'
    });
    wap_url = getPrefs("wap_url");
    param = api.pageParam;
    type = param.type;
    var data = {
        member_id: getPrefs('member_id'),
        member_type:type
    };
    var callback = function (ret) {
        level = ret.content;
        if(getPrefs('token')){
          user = JSON.parse(getPrefs('user'));
          level.invite_code = user.invite_code;
          if(param.invite_code){
            level.invite_code = param.invite_code;
          }
        }else {
          level.invite_code = param.invite_code;
          level.phone = param.phone;
          level.nickname = '';
          user=[];
          user.member_type= 2;
        }
        initApp();
        api.parseTapmode();
    }
    pinet.post(URL.getAddMemberLevelInfo, data, callback);
    addListeners();
};

function initApp() {
    vm = new Vue({
        el: '#app',
        data: {
            level: level,
            level_id:level.level_id,
            activity_id: '',
            nickname:level.nickname,
            phone:level.phone,
            invite_code: level.invite_code,
            imgPath:'../../image/',
        },
        methods: {
          buymember:function(type){
            var attributes = {
                type: type
            };
            openWin('../user/addshop', {type: type});
          },
          addMember: function () {
          if (!this.level_id) {
              alert('请选择等级');
              return;
          }
          showProgress();
          if(user.member_type==2&&type==5){
            var data = {
                member_id: getPrefs('member_id')
            };
            var callback = function (ret) {
                var backData = ret.content;
                lvTypes = backData.levels;
                if(backData.can_update == 0) {
                    pinet.alert(backData.cant_update_reason,closeWin);
                }
                var params = {
                    order_type: 2,
                    foreign_infos: lvTypes.level_id,
                };
                openWin('payment', params);
            };
            pinet.post(URL.upMemberEdit, data, callback);
          }else{
            var data = {
                member_id:getPrefs('member_id'),
                invite_code:this.invite_code,
                level_id:level.level_id
            };
            if(getPrefs('token')){
              order_type = 1;
            }else{
              order_type = 4;
            }
            var callback = function () {
                var params = {
                    foreign_infos: vm.level_id + ';' + vm.activity_id + ';' + vm.nickname + ';' + vm.invite_code + ";" +vm.phone + ";" + getPrefs("jpush_token"),
                    order_type: order_type,
                };
                openWin('payment', params);
            };
            pinet.post(URL.preAddMember, data, callback);
          }
      },
        }
    });
}
function addListeners() {
    api.addEventListener({
        name: 'viewappear'
    }, function () {
        onPageStart();
    });

    api.addEventListener({
        name: 'viewdisappear'
    }, function (ret, err) {
        onPageEnd();
    });

    api.addEventListener({
        name: 'keyback'
    }, function (ret, err) {
        onPageEnd();
        api.closeWin();
    });
}
</script>
</html>
